//
// Created by alexa on 5/13/2024.
//

#ifndef ARTILLERYSYSTEM_UNITREPOSITORY_H
#define ARTILLERYSYSTEM_UNITREPOSITORY_H


#include "../../entities/combat-unit/CombatUnit.h"
#include "../../entities/_identifiable/IdentifiableList.h"

class UnitRepository {
private:
    IdentifiableList<CombatUnit> source;

    string fileSourcePath;
public:
    virtual ~UnitRepository();

    const string &getFileSourcePath() const;

    void setFileSourcePath(const string &fileSourcePath);

    void loadDataFromFile();

    void saveDataToFile();

    explicit UnitRepository(const string &fileSourcePath = "units.json");

    CombatUnit *findById(string id);

    void save(CombatUnit *unit);

    void deleteOne(CombatUnit *unit);

    vector<CombatUnit *> findAll();
};


#endif //ARTILLERYSYSTEM_UNITREPOSITORY_H
